﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Communergy.Common;
using Communergy.Powermeter;
using Communergy.UnitTesting;

namespace CommunergyLogicTests.Helpers
{
    public class PowermeterHelper
    {
        public const string POST_XML  = @"
			<entry xmlns='http://www.w3.org/2005/Atom'
				xmlns:meter='http://schemas.google.com/meter/2008'>
			    <meter:startTime meter:uncertainty='1.0'>2010-04-21T13:30:00.000Z</meter:startTime>
			    <meter:endTime meter:uncertainty='1.0'>2010-04-21T13:45:00.000Z</meter:endTime>
			    <meter:quantity meter:uncertainty='0.001' meter:unit='kW h'>0.642</meter:quantity>
			</entry>";

        public static HistoricalEnergyReading HistoricalReading()
        {
            HistoricalEnergyReading exportData = new HistoricalEnergyReading();
            exportData.ReadingDateTime = new DateTime(2008, 5, 21, 15, 0, 0);
            exportData.KWh = 0.312M;
            exportData.TimeSpan = new TimeSpan(0, 15, 0);
            return exportData;
        }

        public static HistoricalEnergyReading RecentHistoricalReading()
        {
            TimeSpan timeSpan = new TimeSpan(0, 10, 0);
            HistoricalEnergyReading exportData = new HistoricalEnergyReading();
            exportData.ReadingDateTime = DateTime.Now.Subtract(timeSpan);

            exportData.KWh = ((decimal)UnitTestHelper.RandomInt(1,100))/100M;
            exportData.TimeSpan = timeSpan;
            return exportData;
        }
        public static PowermeterData GetTestPowermeterData()
        {
            string userId = "07214542406431945487";
            PowermeterData powerMeterData = new PowermeterData();
            powerMeterData.DeviceName = "Communergy.CurrentCost128.Home";
            powerMeterData.PowermeterBaseUrl = "https://www.google.com/powermeter/feeds/";
            powerMeterData.SecurityZone = userId;
            powerMeterData.UserId = userId;
            powerMeterData.AuthToken = "CI2JxY-5FxCE-6yL_P____8BGMqapMAH";
            return powerMeterData;
        }
    }
}
